package Prototype;

import java.util.Hashtable;

/**
 * @Author: Cjj
 * 原型模式
 */
public class ShapeCache {
    public static Hashtable<String,Shape>shapeMap=new Hashtable<String,Shape>();
    public static Shape getShape(String shapeId)
    {
        Shape cachedShape=shapeMap.get(shapeId);
        return (Shape) cachedShape.clone();
    }

  public class PrototypePatternDemo {
      public static void main(String[] args)
      {

          Shape clonedShape=ShapeCache.getShape("1");
          System.out.println("Shape:"+clonedShape.getType());

          Shape clonedShape2=ShapeCache.getShape("2");
          System.out.println("Shape:"+clonedShape2.getType());

          Shape clonedShape3=ShapeCache.getShape("3");
          System.out.println("shape:"+clonedShape3.getType());
      }
  }


}
